﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace PercentageCropper1
{
    class ImageCropper
    {
        String      m_imageName;
        CropInfo    m_cropInfo;
        public ImageCropper(String imageName, CropInfo e) 
        {
            m_imageName = imageName;
            m_cropInfo  = e;
        }

        public Image Action() 
        {
            Image img = Image.FromFile(m_imageName);
            int newWidth = (int)Math.Ceiling(img.Width * (1 - m_cropInfo.WidthPerc));
            int newHeight = (int)Math.Ceiling(img.Height* (1- m_cropInfo.HeightPerc));
            img = ImageLib.cropImage(img, 
                                    new Rectangle(m_cropInfo.X, 
                                                    m_cropInfo.Y,
                                                    newWidth, 
                                                    newHeight));
            return img;
        }
    }
}
